<template>
  <div class="journal">
    <el-dialog
      title="日志"
      :close-on-click-modal="false"
      :visible.sync="dialogTableVisible"
      width="80%"
      @close="callback"
    >
      <custom-table :data="listData" :columns="columns">
        <template slot-scope="{ row }">
          <el-button type="text" @click="getDetail(row)">查看对象</el-button>
          <el-button
            :disabled="row.status === 'ignore' ? true : false"
            type="text"
            @click="getProcess(row)"
          >无效举报</el-button>
        </template>
      </custom-table>
      <pagination :total="total" @pagination="pagination" />

      <div slot="footer" class="dialog-footer">
        <el-button @click="callback">取 消</el-button>
        <el-button type="primary" @click="callback">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { operateLogFindPage } from '@/api/activity';
import CustomTable from '@/components/CustomTable/index';
import Pagination from '@/components/Pagination/index';
export default {
  name: 'Journal',
  components: {
    CustomTable,
    Pagination
  },
  props: ['dialogVisible', 'dialogObj'],
  data () {
    return {
      listData: [],
      dialogTableVisible: this.dialogVisible,

      listQuery: {
        condition: this.dialogObj,
        pager: {
          page: 1,
          pageSize: 10
        }
      },
      total: 15,
      columns: [
        { label: '序号', value: 'index', width: '80px', align: 'center' },
        { label: '操作时间', value: 'createTime', width: '160px', align: 'center' },
        { label: '描述', value: 'des', align: 'center' },
        { label: '状态', value: 'stateTxt', width: '100px', align: 'center' },
        { label: '操作用户', value: 'userId', width: '220px', align: 'center' },
        { label: '系统', value: 'sysEnum', width: '120px', align: 'center' }
      ]
    };
  },
  computed: {
  },
  watch: {
    dialogObj: {
      deep: true,
      handler (data) {
        this.listQuery.condition = data;
        this.init();
      }
    },
    dialogVisible: {
      deep: true,
      handler (data) {
        this.dialogTableVisible = data;
      }
    }
  },
  created () {
  },
  methods: {
    callback () {
      this.dialogTableVisible = false;
      this.$emit('Callback', this.dialogTableVisible);
    },

    pagination ({ page, limit }) {
      this.listQuery.pager.page = page;
      this.listQuery.pager.pageSize = limit;
      this.init();
    },

    init () {
      operateLogFindPage(this.listQuery).then(res => {
        console.log('日志：', res.data);
        res.data.records.map(item => {
          item.stateTxt = item.state ? '操作成功' : '操作失败';
        });
        this.listData = res.data.records;
        this.total = res.data.total;
      });
    }
  }
};
</script>

<style lang='scss' scoped>
</style>
